﻿<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script type="text/javascript" th:src="@{/js/inputDel.js}" ></script>
<script type="text/javascript" th:src="@{/home/js/public.js}"></script>
</head>
<body>
	<div class="navigation-t">
		<div class="navigation-tl">
			当前位置：<a href="#" onclick="changeMain('home')">主页</a> > 用户管理
		</div>
		<div class="navigation-tr">
			<ul>
				<li onclick="changeMain('operation/user/1?timestamp='+new Date().getTime())" class="active"><span>用户管理</span></li>
				<li onclick="changeMain('operation/authority/1?timestamp='+new Date().getTime())"><span>权限管理</span></li>
				<li onclick="changeMain('password')"><span>修改密码</span></li>
			</ul>
		</div>
	</div>
	<div class="project">
		<div class="project-padding">
			<div class="table-tool project-t">
				<div class="table-tool-btn">
					<div class="tool-btn" id="user-add">
						<span class="add-icon"></span><a>新增</a>
					</div>
					<div class="tool-btn" id="user-edit">
						<span class="edit-icon"></span><a>编辑</a>
					</div>
					<div class="tool-btn" id="user-del">
						<span class="del-icon"></span><a>删除</a>
					</div>
					<div class="tool-btn"  id="user-passwordReset">
						<span class="czmm-icon"></span><a>密码重置</a>
					</div>
				</div>
				<div class="table-tool">
					<div class="table-tool-ser">
						<div class="tool-ser">
							<input type="text" class="form-control" placeholder="输入查询条件"
								id="search1" />
						</div>
						<div class="tool-btn" onclick="js_method()">
							<span class="ser-icon"></span><a>搜索</a>
						</div>
					</div>
				</div>
			</div>
			<!--内容开始-->
			<div class="table-head">
				<table width="100%" align="center" cellpadding="0" cellspacing="0"
					border="0"  id="table">
					<thead>
						<tr>
							<td width="4%"><input type="checkbox"  /></td>
							<td width="6%">序号</td>
							<td style="display: none">id</td>
							<td width="30%">用户名称</td>
							<td width="30%">用户角色</td>
							<td width="30%">备注</td>
						</tr>
					</thead>
					<tbody>
						<tr th:each="row,iterStat : ${rows}">
							<td ><input type="checkbox" name="select_item" /></td>
							<td th:text="${iterStat.count}">1</td>
							<td  name="id" th:text="${row.id}" style="display: none">id</td>
							<td th:text="${row.userName}"></td>
							<td th:text="${row.roleName}"></td>
							<td th:text="${row.userRemark}">备注内容</td>
						</tr>
					</tbody>
				</table>
			</div>
			<!--内容结束-->
			<!--分页开始-->

			<div class="multimedia-c">
				<ul class="pagination" id="pagination">
				</ul>
				<input type="hidden" id="PageCount" runat="server" /> <input
					type="hidden" id="PageSize" runat="server" value="5" /> <input
					type="hidden" id="countindex" runat="server" value="10" />
				<!--设置最多显示的页码数 可以手动设置 默认为4-->
				<input type="hidden" id="visiblePages" runat="server" value="4" />
			</div>
			<!--分页结束-->
		</div>
	</div>
</body>
<script src="home/js/HomePage.js" type="text/javascript"></script>
<script th:inline="javascript">  

/*<![CDATA[*/  
           
           
    
           
           
           
           
           
           
           
	$(function() {
		$('#user-add').on('click', function(e) {
			e.preventDefault();
			var diag1 = new $.Zebra_Dialog({
				source : {
					'iframe' : {
						'id':'user',
						'src' : 'user-add.html?timestamp='+new Date().getTime(),
						'height' : 300
					}
				},
				width : 600,
				title : '新增',
			    buttons:  [
			                 {caption: '保存', callback: function() { 
			                		var validate=document.getElementById("user").contentWindow.getData();
				            		  if(!validate){
				            			 return false;
				            		 }
			            	   var data= document.getElementById("user").contentWindow.getDataJson("userForm");
			           		   var obj = JSON.stringify(data);
			       		       AjaxWebTableInfo("/User/saveOrUpdate",data);
			                  }}
	                        ]
			});
		});
		$('#user-edit').on('click', function(e) {
			e.preventDefault();
			if($('input[name="select_item"]:checked').length==1){
				var checkBoxs= $('input[name="select_item"]:checked').parent();
				var id=checkBoxs.parent().parent().find("[name='id']").text();
				var diag = new $.Zebra_Dialog({
					source : {
						'iframe' : {
							'id':'user',
							'src' : 'edit/user-edit.html?timestamp='+new Date().getTime()+'&id='+id,
							'height' : 300
						}
					},
					width : 600,
					title : '编辑',
				    buttons:  [
				               {caption: '保存', callback: function() { 
				            		var validate=document.getElementById("user").contentWindow.getData();
				            		  if(!validate){
				            			 return false;
				            		 }
				            	   var data= document.getElementById("user").contentWindow.getDataJson("userForm");
				           		   var obj = JSON.stringify(data);
				       		       AjaxWebTableInfo("/User/saveOrUpdate",data);
				                  }}
		                        ]
				});
				
				
				
			}else{
				 $.Zebra_Dialog('<div class="prompt"><div class="warning-icon"></div><div class="success-title">请选中一行!</div></div>', {
			            'title':'提示',
			            'buttons':['确定']
			         });
			}
		
		});
		
		$('#user-del').on('click', function(e) {
			e.preventDefault();
			var checkBoxs= $('input[name="select_item"]:checked').parent();
			var ids=checkBoxs.parent().parent().find("[name='id']");
		    var  id="";
  		   for (var i=0;i<ids.length;i++)
			{
  				if(i<ids.length-1){
  					id += $(ids[i]).text()+",";
  				}else{
  					id += $(ids[i]).text();
  				}
			} 
  		   
  		 $.ajax({
		     type: "post",
		     dataType: "json",
		     url:"/User/dele" ,
		     data:{id:id},
		     success: function (data, status) {
		    	 $.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">删除成功!</div></div>', {
			            'title':'提示',
			            'buttons':['确定']
			         });
		  	    $("#frameReft").load("/operation/user/1?timestamp="+new Date().getTime());
		     },
		     error: function (data) {
		    	 $.Zebra_Dialog('<div class="prompt"><div class="error-icon"></div><div class="success-title">删除失败!</div></div>', {
			            'title':'提示',
			            'buttons':['确定']
			         });
		     }
		 });
  		   
		 });
		
		
		$('#user-passwordReset').on('click', function(e) {
			e.preventDefault();
			if($('input[name="select_item"]:checked').length==1){
				var checkBoxs= $('input[name="select_item"]:checked').parent();
				var id=checkBoxs.parent().parent().find("[name='id']").text();
				 $.ajax({
				     type: "post",
				     dataType: "json",
				     url:"/User/passwordReset" ,
				     data:{id:id},
				     success: function (data, status) {
				    	 $.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">密码重置成功!</div></div>', {
					            'title':'提示',
					            'buttons':['确定']
					         });
				  	    $("#frameReft").load("/operation/user/1?timestamp="+new Date().getTime());
				     },
				     error: function (data) {
				    	 $.Zebra_Dialog('<div class="prompt"><div class="error-icon"></div><div class="success-title">密码重置失败!</div></div>', {
					            'title':'提示',
					            'buttons':['确定']
					         });
				     }
				 });
				
				
			}else{
				 $.Zebra_Dialog('<div class="prompt"><div class="warning-icon"></div><div class="success-title">请选中一行!</div></div>', {
			            'title':'提示',
			            'buttons':['确定']
			         });
			}
  		   
  
  		   
		 });
	})
	function AjaxWebTableInfo(url , obj){
		 $.ajax({
		     type: "post",
		     dataType: "json",
		     url: url,
		     data:obj,
		     success: function (data, status) {
		    	 $.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">没有权限</div></div>', {
			            'title':'提示',
			            'buttons':['确定']
			         });
		  	    $("#frameReft").load("/operation/user/1?timestamp="+new Date().getTime());
		     },
		     error: function (data) {
		    	 $.Zebra_Dialog('<div class="prompt"><div class="error-icon"></div><div class="success-title">保存失败!</div></div>', {
			            'title':'提示',
			            'buttons':['确定']
			         });
		     }
		 });	
	}
	/*]]>*/  
	
</script>
<script th:inline="javascript">  
/*<![CDATA[*/  
    var total ="[[${total}]]";
    var pageNo ="[[${pageNo}]]"; 
    var  search=[[${search}]]
    $("#search1").val(search);
    $("#PageCount").val(total);
    loadpage(pageNo,"operation/user/",$("#search1").val());
	function js_method(){
	 var search= $("#search1").val();
	 $("#frameReft").load("/operation/user/1?timestamp="+new Date().getTime(),{'search': search});
	}
	
/*]]>*/  
</script>

</html>
